﻿using Microsoft.AspNetCore.Mvc;
using mozhi.smarterp.Finance.Querys;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp;

namespace mozhi.smarterp.Finance.Banks
{
    [RemoteService]
    [Route("api/v1/bankaccounts")]
    public class BankAccountController : BaseController
    {
        private IBankAccountAppService _appService;
        public BankAccountController(IBankAccountAppService appService)
        {
            _appService = appService;
        }

        [HttpGet]
        public async Task<List<BankAccountDto>> GetAsync(BankResultRequestDto filter)
        {
            var bankAccounts = await _appService.GetListAsync(filter);

            return bankAccounts;
        }

        [HttpGet]
        [Route("{id}")]
        public async Task<BankAccountDto> GetAsync(Guid id)
        {
            var bankAccount = await _appService.GetAsync(id);
            return bankAccount;
        }

        [HttpPost]
        public async Task<BankAccountDto> CreateAsync(BankAccountCreateDto bankAccount)
        {
            var result = await _appService.CreateAsync(bankAccount);

            return result;
        }

        [HttpPut]
        [Route("{id}")]
        public async Task<BankAccountDto> UpdateAsync(BankAccountUpdateDto bankAccount)
        {
            var result = await _appService.UpdateAsync(bankAccount);

            return result;
        }

        [HttpDelete]
        [Route("{id}")]
        public async Task DeleteAsync(Guid id)
        {
            await _appService.DeleteAsync(id);
        }
    }
}
